Passed
Push — master ( 1029c0...f58cd4 )
by Mathieu
01:51 queued 22s
created

Discount.getValue   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
1
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
2
import { School } from './School.entity';
3
4
export enum DiscountType {
5
  PERCENT = 'percent',
6
  AMOUNT = 'amount'
7
}
8
9
@Entity()
10
export class Discount {
11
  @PrimaryGeneratedColumn('uuid')
12
  private id: string;
13
14
  @Column('enum', { enum: DiscountType, nullable: false })
15
  protected type: DiscountType;
16
17
  @Column({ type: 'integer', nullable: false })
18
  private amount: number;
19
20
  @Column({ type: 'integer', nullable: false })
21
  private value: number;
22
23
  @ManyToOne(() => School, { nullable: false, onDelete: 'CASCADE' })
24
  private school: School;
25
26
  constructor(
27
    type: DiscountType,
28
    amount: number,
29
    value: number,
30
    school: School
31
  ) {
32
    this.type = type;
33
    this.amount = amount;
34
    this.value = value;
35
    this.school = school;
36
  }
37
38
  public getId(): string {
39
    return this.id;
40
  }
41
42
  public getAmount(): number {
43
    return this.amount;
44
  }
45
46
  public getValue(): number {
47
    return this.value;
48
  }
49
50
  public getType(): DiscountType {
51
    return this.type;
52
  }
53
54
  public getSchool(): School {
55
    return this.school;
56
  }
57
}
58